/**
 * 2017，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	VehicleFlowDaoImpl.java
 * Created：		2017年4月27日
 * Creator：		wolv
 */
package com.thor.palmmall.dao.rpt.vehicleflow;

import java.util.List;

import javax.persistence.Query;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.thor.commons.exception.ThorServiceException;
import com.thor.commons.util.Assert;
import com.thor.dao.BasicDao;
import com.thor.palmmall.api.rpt.Report;
import com.thor.palmmall.api.rpt.vehicleflow.DailyVehicleFlowReportParam;

/**
 * @author wolv
 *
 */
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NOT_SUPPORTED)
public class VehicleFlowRptDaoImpl extends BasicDao implements VehicleFlowRptDao {

	@SuppressWarnings("unchecked")
	public Report calcDailyReport(DailyVehicleFlowReportParam param) throws ThorServiceException {
		Assert.assertArgumentNotNull(param, "param");

		param.validate();

		Query query = DailyVehicleFlowReportHqlBuilder.getInstance().build(param);
		List<Object[]> rawReports = query.getResultList();

		return Report.readFrom(rawReports);
	}
}
